home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / AHDI / TSTDRIVE / CHECK.S < prev    next >
Encoding:
Text File  |  2001-02-09  |  6.7 KB  |  217 lines

  1. ;+
  2. ;  CHECK.S - check for existence of different components in system.
  3. ;-
  4.  
  5. .include    "defs.h"
  6. .include    "68030.s"
  7.  
  8. REGBASE    equ    1            ; most are on odd part of data bus
  9. bSCSI    equ    $FFFF8780+REGBASE    ; base address of SCSI bus
  10. bAT    equ    $FFF00000+REGBASE    ; base address of AT bus
  11. WDC    equ    $FFFF8604        ; base address of ACSI bus
  12. _MCH    equ    $5f4d4348           ; _MCH
  13.  
  14. ;+
  15. ; chkspscsi() - Check if we are on a Sparrow.  If so, there is Sparrow SCSI
  16. ;-
  17.     .extern    _getcookie
  18.     .globl    _chkspscsi
  19. _chkspscsi:
  20.     move.l    #machine,-(sp)        ; ptr to machine type
  21.     move.l    #_MCH,-(sp)        ; looking for _MCH cookie
  22.     bsr    _getcookie
  23.     addq.w    #8,sp            ; clean up stack
  24.     moveq    #0,d0            ; assume we are NOT on a Sparrow
  25.     cmpi.l    #SPARROW,machine    ; are we?
  26.     bne.s    nosp
  27.     moveq    #1,d0            ; else, there is Sparrow SCSI
  28. nosp:    rts
  29.  
  30. ;+
  31. ; chkscsi() - Check if SCSI bus exists
  32. ;
  33. ; Uses: d0, d1, d2, a0, a1
  34. ;-
  35.     .globl    _chkscsi
  36. _chkscsi:                ; check if SCSI exists
  37.     move.l    #0,savssp        ; no stack pointer is saved yet
  38.     move.l    #1,-(sp)        ; find out what mode processor is in
  39.     move.w    #$20,-(sp)        ; Super(1L)
  40.     trap    #1
  41.     addq.w    #6,sp            ; clean up stack
  42.     tst.w    d0            ; in Supervisor mode already?
  43.     bne.s    tscsi            ; if so, go test for SCSI
  44.     clr.l    -(sp)            ; else go to Supervisor mode
  45.     move.w    #$20,-(sp)        ; Super(0L)
  46.     trap    #1
  47.     addq.w    #6,sp            ; clean up stack
  48.     move.l    d0,savssp        ; save original stack pointer
  49. tscsi:    clr.w    result            ; assume SCSI doesn't exist
  50.     movea.l    BERR,a0            ; save original bus error vector
  51.     move.l    #nbus,BERR        ; install our own vector
  52.     movea.l    sp,a1            ; save current stack pointer
  53.     move.b    bSCSI,d1        ; try to access the SCSI bus
  54.     move.w    #1,result        ; if no bus error, SCSI exists
  55. nbus:    move.l    a0,BERR            ; restore original bus error vector
  56.     move.l    a1,sp            ; restore stack pointer
  57. chkret:    tst.l    savssp            ; were we in User mode when started?
  58.     beq.s    tend            ; if not, just return
  59.     move.l    savssp,-(sp)        ; go back to User mode 
  60.     move.w    #$20,-(sp)        ; Super(savssp)
  61.     trap    #1
  62.     addq.w    #6,sp            ; clean up stack
  63. tend:    move.w    result,d0        ; d0 = result
  64.     rts
  65.  
  66.  
  67. ;+
  68. ; chkacsi() - Check if ACSI bus exists
  69. ;
  70. ; Uses: d0, d1, d2, a0, a1
  71. ;-
  72.     .globl    _chkacsi
  73. _chkacsi:                ; check if SCSI exists
  74.     move.l    #0,savssp        ; no stack pointer is saved yet
  75.     move.l    #1,-(sp)        ; find out what mode processor is in
  76.     move.w    #$20,-(sp)        ; Super(1L)
  77.     trap    #1
  78.     addq.w    #6,sp            ; clean up stack
  79.     tst.w    d0            ; in Supervisor mode already?
  80.     bne.s    tacsi            ; if so, go test for SCSI
  81.     clr.l    -(sp)            ; else go to Supervisor mode
  82.     move.w    #$20,-(sp)        ; Super(0L)
  83.     trap    #1
  84.     addq.w    #6,sp            ; clean up stack
  85.     move.l    d0,savssp        ; save original stack pointer
  86. tacsi:    clr.w    result            ; assume SCSI doesn't exist
  87.     movea.l    BERR,a0            ; save original bus error vector
  88.     move.l    #nbus,BERR        ; install our own vector
  89.     movea.l    sp,a1            ; save current stack pointer
  90.     move.w    WDC,d1            ; try to access the ACSI bus
  91.     move.w    #1,result        ; if no bus error, ACSI exists
  92.     bra    nbus
  93.  
  94.  
  95. ;+
  96. ; chkide() - Check if IDE bus exists
  97. ;
  98. ; Uses: d0, d1, d2, a0, a1
  99. ;-
  100.     .globl    _chkide
  101. _chkide:                    ; check if AT bus exists
  102.     move.l    #0,savssp        ; no stack pointer is saved yet
  103.     move.l    #1,-(sp)        ; find out what mode processor is in
  104.     move.w    #$20,-(sp)        ; Super(1L)
  105.     trap    #1
  106.     addq.w    #6,sp            ; clean up stack
  107.     tst.w    d0            ; in Supervisor mode already?
  108.     bne.s    tide            ; if so, go test for AT
  109.     clr.l    -(sp)            ; else go to Supervisor mode
  110.     move.w    #$20,-(sp)        ; Super(0L)
  111.     trap    #1
  112.     addq.w    #6,sp            ; clean up stack
  113.     move.l    d0,savssp        ; save original stack pointer
  114. tide:    clr.w    result            ; assume AT bus doesn't exist
  115.     movea.l    BERR,a0            ; save original bus error vector
  116.     move.l    #nbus,BERR        ; install our own vector
  117.     movea.l    sp,a1            ; save current stack pointer
  118.     move.b    bAT,d1            ; try to access the AT bus
  119.     move.w    #1,result        ; if no bus error, AT exists
  120.     bra    nbus
  121.  
  122.  
  123. ;+
  124. ; chkblit() - Check if BLiTTER exists
  125. ;
  126. ; Uses: d0
  127. ;-
  128.     .globl    _chkblit
  129. _chkblit:
  130.     move.w    #-1,-(sp)
  131.     move.w    #64,-(sp)        ; blitmode(-1)
  132.     trap    #14
  133.     addq.w    #4,sp            ; clean up stack
  134.     btst    #1,d0            ; does BLiTTER exist?
  135.     beq.s    nblit
  136.     moveq    #1,d0            ; return 1 if exists
  137.     rts
  138. nblit:    moveq    #0,d0            ; return 0 if not
  139.     rts
  140.  
  141.  
  142. ;+
  143. ; chkcache() - Check if '030 cache exists
  144. ;
  145. ; Uses: d0, d1, d2, a0, a1
  146. ;-
  147.     .globl    _chkcache
  148. _chkcache:                ; check if '030 cache exists
  149.     move.l    #0,savssp        ; no stack pointer is saved yet
  150.     move.l    #1,-(sp)        ; find out what mode processor is in
  151.     move.w    #$20,-(sp)        ; Super(1L)
  152.     trap    #1
  153.     addq.w    #6,sp            ; clean up stack
  154.     tst.w    d0            ; in Supervisor mode already?
  155.     bne.s    tcache            ; if so, go test for cache
  156.     clr.l    -(sp)            ; else go to Supervisor mode
  157.     move.w    #$20,-(sp)        ; Super(0L)
  158.     trap    #1
  159.     addq.w    #6,sp            ; clean up stack
  160.     move.l    d0,savssp        ; save original stack pointer
  161. tcache:    clr.w    result            ; assume cache doesn't exist
  162.     movea.l    IINS,a0            ; save orig illegal instrn vector
  163.     move.l    #ncache,IINS        ; install our own vector
  164.     movea.l    sp,a1            ; save current stack pointer
  165.     movecacrd0            ; does a cache exist?
  166.     move.w    #1,result        ; if so, set result
  167. ncache:    move.l    a0,IINS            ; restore orig illegal instrn vector
  168.     move.l    a1,sp            ; restore stack pointer
  169.     bra    chkret
  170.  
  171.  
  172. ;+
  173. ; _Stbook() - to find out if driver is being run on the ST Book.
  174. ;
  175. ; Comments:
  176. ;    On the ST Book, the palette registers are only readable.
  177. ; So, to determine if the driver is being run on the ST Book, write
  178. ; to the palette registers, and then read them back.  If what read
  179. ; back isn't the same as what's been written, it IS an ST Book.
  180. ; The palette starts at address $ffff8240.
  181. ;-
  182.     .globl  _stbook
  183. _stbook:
  184.     move.l    #0,savssp        ; no stack pointer is saved yet
  185.     move.l    #1,-(sp)        ; find out what mode processor is in
  186.     move.w    #$20,-(sp)        ; Super(1L)
  187.     trap    #1
  188.     addq.w    #6,sp            ; clean up stack
  189.     tst.w    d0            ; in Supervisor mode already?
  190.     bne.s    tbook            ; if so, go test if it's STBook
  191.     clr.l    -(sp)            ; else go to Supervisor mode
  192.     move.w    #$20,-(sp)        ; Super(0L)
  193.     trap    #1
  194.     addq.w    #6,sp            ; clean up stack
  195.     move.l    d0,savssp        ; save original stack pointer
  196. tbook:    move.l  $ffff8242,d2        ; save palette registers old values
  197.     move.w  #$0555,$ffff8242    ; write new pattern to 1st register
  198.     move.w  #$0222,$ffff8244    ; write new pattern to 2nd register
  199.     move.w  #1,result        ; assume it IS an ST Book
  200.     move.w  $ffff8242,d1        ; read from 1st palette register
  201.     and.w   #$0777,d1        ; mask out useless bits
  202.     cmp.w   #$0555,d1        ; value stays the same?
  203.     bne.s   .0            ; if not, it IS an ST Book
  204.     move.w  $ffff8244,d1        ; read from 2nd palette register
  205.     and.w   #$0777,d1        ; mask out useless bits
  206.     cmp.w   #$0222,d1        ; value stays the same?
  207.     bne.s   .0            ; if not, it IS an ST Book
  208.     move.w  #0,result        ; else, it is NOT an ST Book
  209.     move.l  d2,$ffff8242        ; restore palette registers
  210. .0:    bra    chkret    
  211.  
  212.  
  213. .bss
  214. savssp:        ds.l    1            ; stack pointer
  215. result:        ds.w    1
  216. machine:    ds.l    1
  217.